package com.example.handlers;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

import java.util.ArrayList;
import java.util.List;

@Component
public class UserHandler {
    List<String> objects = new ArrayList<>();
    {
        objects.add("1");
        objects.add("11");
        objects.add("111");
        objects.add("1111");
    }


    public Mono<ServerResponse> getAllUser(ServerRequest request) {
        List<String> objects = new ArrayList<>();
        objects.add("1");
        objects.add("11");
        objects.add("111");
        objects.add("1111");
        return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON)
                .body(objects, String.class);
    }

    public Mono<ServerResponse> createUser(ServerRequest request) {
        Mono<List> mono = request.bodyToMono(List.class);


        return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON)
                .body(mono, List.class);
    }


//    Mono<ServerResponse> deleteUserById(ServerRequest request) {
//        String id = request.pathVariable("id");
//
//
//        return objects.stream().filter().flatMap()
//    }
}
